import java.lang.reflect.Method;

import highvoltage.*;
import highvoltage.skeletonHelpers.*;

/**
 * A skeleton belépési pontját tartalmazó osztály.
 * 
 * @author sztomi
 * 
 */
public class Skeleton
{
	public static void main( String[] args )
	{
		Logger.print( "Main::main" );

		System.out.println( "Valaszthato tesztek: " );
		System.out.println( "  1. teszt: step mukodese" );
		System.out.println( "  2. teszt: belepes keresztezodesbe" );
		System.out.println( "  3. teszt: jarmuvek utkozese" );
		System.out.println( "  4. teszt: jarmuvek elnyelodese" );

		int choice = UserInput.choice( "Valasztas", new int[] {1, 2, 3, 4 } );

		try
		{
			Method toCall = Skeleton.class.getMethod( String.format( "test_%d", choice ) );
			toCall.invoke( null );
		}
		catch ( Exception e )
		{
			e.printStackTrace();
		}
	}

	public static void test_1()
	{
		Logger.print( "1. teszt: step mukodese" );

		Logger.call( "Timer::Timer()" );
		Timer timer = new Timer();

		World world = World.getInstance();

		Logger.call( "RoadSegment::RoadSegment()" );
		RoadSegment elso = new RoadSegment();

		Logger.call( "RoadSegment::init()" );
		elso.init();

		Logger.call( "RoadSegment::RoadSegment()" );
		RoadSegment masodik = new RoadSegment();

		Logger.call( "RoadSegment::init()" );
		masodik.init();

		Logger.call( "RoadSegment::addOutgoingSegment()" );
		elso.addOutgoingSegment( masodik );

		Logger.call( "RoadSegment::addIncomingSegment()" );
		masodik.addIncomingSegment( elso );

		Logger.call( "Timer::setObj()", timer );
		timer.setObj( world );

		Logger.call( "Timer::start()", timer );
		timer.start();
	}

	public static void test_2()
	{
		Logger.print( "2. teszt: belepes utelembe, iranyvalasztassal" );

		Logger.call( "Timer::Timer()" );
		Timer timer = new Timer();

		Logger.call( "World::World()" );

		Logger.call( "RoadSegment::RoadSegment()" );
		RoadSegment elso = new RoadSegment();

		Logger.call( "RoadSegment::init()" );
		elso.init();

		Logger.call( "RoadSegment::RoadSegment()" );
		RoadSegment masodik = new RoadSegment();

		Logger.call( "RoadSegment::init()" );
		masodik.init();

		Logger.call( "RoadSegment::addOutgoingSegment()" );
		elso.addOutgoingSegment( masodik );

		Logger.call( "RoadSegment::addIncomingSegment()" );
		masodik.addIncomingSegment( elso );

		Logger.ret();

		Logger.call( "Timer::setObj(world)" );
		timer.setObj( World.getInstance() );

		Logger.call( "Timer::start()" );
		timer.start();

	}

	public static void test_3()
	{
		Logger.print( "3. tesz: jarmuvek utkozese" );

		System.out.println( "Valaszthato tesztek: " );
		System.out.println( "  1. teszt: Rablo utkozese civillel" );
		System.out.println( "  2. teszt: Rablo utkozese rendorrel" );

		int choice = UserInput.choice( "Valasztas", new int[] {1, 2 } );

		try
		{
			Method toCall = Skeleton.class.getMethod( String.format( "test_3_%d", choice ) );
			toCall.invoke( null );
		}
		catch ( Exception e )
		{
			e.printStackTrace();
		}

	}

	public static void test_3_1()
	{
		Logger.call( "RoadSegment::RoadSegment()" );
		RoadSegment rs = new RoadSegment();

		Logger.call( "RoadSegment::init()" );
		rs.init();

		Logger.call( "Robber::Robber()" );
		Vehicle robber = new Robber();

		Logger.call( "VehicleWrapper::VehicleWrapper()" );
		VehicleWrapper vw = new VehicleWrapper( robber );

		Logger.call( String.format( "RoadSegment::enter( vw | %d )", vw.hashCode() ) );
		rs.enter( vw );
	}

	public static void test_3_2()
	{
		Logger.call( "PoliceStation::PoliceStation()" );
		RoadSegment ps = new PoliceStation();

		Logger.call( "PoliceStation::init()" );
		ps.init();

		Logger.call( "Robber::Robber()" );
		Vehicle robber = new Robber();

		Logger.call( "VehicleWrapper::VehicleWrapper()" );
		VehicleWrapper vw = new VehicleWrapper( robber );

		Logger.call( String.format( "RoadSegment::enter( vw | %d )", vw.hashCode() ) );
		ps.enter( vw );

	}

	public static void test_4()
	{
		Logger.print( "4. teszt: jarmuvek megsemmisulese" );

		System.out.println( "Valaszthato tesztek: " );
		System.out.println( "  1. teszt: Rablo elnyelodese rejtekhelyen" );
		System.out.println( "  1. teszt: Rablo elnyelodese varoshataron" );
		System.out.println( "  3. teszt: Civil elnyelodese varoshataron" );
		System.out.println( "  4. teszt: Rendor elnyelodese varoshataron" );

		int choice = UserInput.choice( "Valasztas", new int[] {1, 2, 3, 4 } );

		try
		{
			Method toCall = Skeleton.class.getMethod( String.format( "test_4_%d", choice ) );
			toCall.invoke( null );
		}
		catch ( Exception e )
		{
			e.printStackTrace();
		}

	}

	/**
	 * Rabló "elnyelődése" rejtekhelyen
	 */
	public static void test_4_1()
	{
		Logger.call( "HideOut::HideOut()" );
		RoadSegment ho = new HideOut();

		Logger.call( "Robber::Robber()" );
		Vehicle robber = new Robber();

		Logger.call( "VehicleWrapper::VehicleWrapper()" );
		VehicleWrapper vw = new VehicleWrapper( robber );

		Logger.call( String.format( "RoadSegment::enter( vw | %d )", vw.hashCode() ) );
		ho.enter( vw );
	}
	
	/**
	 * Rabló "elnyelődése" városhatáron
	 */
	public static void test_4_2()
	{
		Logger.call( "HideOut::HideOut()" );
		RoadSegment drs = new DrainRoadSegment();

		Logger.call( "Robber::Robber()" );
		Vehicle robber = new Robber();

		Logger.call( "VehicleWrapper::VehicleWrapper()" );
		VehicleWrapper vw = new VehicleWrapper( robber );

		Logger.call( String.format( "RoadSegment::enter( vw | %d )", vw.hashCode() ) );
		drs.enter( vw );
	}

	/**
	 * Civil "elnyelődése" városhatáron
	 */
	public static void test_4_3()
	{
		Logger.call( "DrainRoadSegment::DrainRoadSegment()" );
		RoadSegment drs = new DrainRoadSegment();

		Logger.call( "Civilian::Civilian()" );
		Vehicle civ = new Civilian();

		Logger.call( "VehicleWrapper::VehicleWrapper()" );
		VehicleWrapper vw = new VehicleWrapper( civ );

		Logger.call( String.format( "RoadSegment::enter( vw | %d )", vw.hashCode() ) );
		drs.enter( vw );
	}

	/**
	 * Rendőr "elnyelődése" városhatáron
	 */
	public static void test_4_4()
	{
		Logger.call( "DrainRoadSegment::DrainRoadSegment()" );
		RoadSegment drs = new DrainRoadSegment();

		Logger.call( "Police::Police()" );
		Vehicle pol = new Police();

		Logger.call( "VehicleWrapper::VehicleWrapper()" );
		VehicleWrapper vw = new VehicleWrapper( pol );

		Logger.call( String.format( "RoadSegment::enter( vw | %d )", vw.hashCode() ) );
		drs.enter( vw );
	}

}
